package com.bridgeintelligent.tag.bulkload.service.core.iterator;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created by JackCheung on 2019/9/23 11:56 PM.
 */
public interface BulkIterator<E> extends Iterator<E> {

    /**
     * 截取指定数量的元素到集合中
     *
     * @param count
     * @return
     */
    default List<E> subList(int count) {
        List<E> elements = new ArrayList<>(count);
        for (int i = 0; (this.hasNext() && (i < count)); i++) {
            elements.add(next());
        }
        return elements;
    }
}
